#include"mytime.h"

Time::Time()
{
	this->hours = 0;
	this->minutes = 0;
}

Time::Time(int h, int m)
{
	this->hours = h;
	this->minutes = m;
}

void Time::AddMin(int m)
{
	minutes += m;
	hours += minutes / 60;
	minutes %= 60;
}

void Time::AddH(int h)
{
	hours += h;
}

void Time::Reset(int h, int m)
{
	hours = h;
	minutes = m;
}

Time Time::operator+(const Time& t)const
{
	Time sum;
	sum.minutes = minutes + t.minutes;
	sum.hours = hours + sum.minutes / 60;
	sum.minutes %= 60;
	return sum;
}

Time Time::operator-(const Time& t)const
{
	int min = hours * 60 + minutes - t.hours * 60 - t.minutes;
	Time st;
	st.hours = min / 60;
	st.minutes = min % 60;
	return st;
}

Time Time::operator*(double n)const
{
	Time mt;
	long total = hours * n * 60 + minutes * n;
	mt.hours = total / 60;
	mt.minutes = total % 60;
	return mt;
}

std::ostream& operator<<(std::ostream& os, const Time& t)
{
	os << "Hours: " << t.hours << ",Minutes: " << t.minutes;
	return os;
}